﻿using MESPro.Controls;
using MESPro.Enums;
using MESPro.Models.FunctionType;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MESPro.Models
{
    /// <summary>
    /// 每次我们得到一个Function后,就请把得到他的TreeControls
    /// 一个功能就是一个页面(俗称插件?),多个页面可以组成一个FunctionGroup功能组(多对多),页面下面有多个控件组
    /// </summary>
    [Tenant("Default")]
    public class Function : EntityBaseIdNameCreat
    {

        #region 属性
        /// <summary>
        /// 新增时候要执行存储过程
        /// </summary>
        [Category("\t\t\t\t\t\t\t数据源"),
        Description("新增时候要执行存储过程名"),
        DisplayName("\t\t\t\t新增"),
        TypeConverter(typeof(ExpandableObjectConverter)),
        Editor(typeof(PropertyReturnStoreProcedure), typeof(UITypeEditor))    ]
        [SugarColumn(IsJson = true)]
        public StoreProInfo InsertStoredProcedure { get; set; } = new();

        /// <summary>
        /// 要执行删除时存储过程
        /// </summary>
        [Category("\t\t\t\t\t\t\t数据源"), Description("要执行删除时存储过程名"), DisplayName("\t\t\t删除")]
        [TypeConverter(typeof(ExpandableObjectConverter)), Editor(typeof(PropertyReturnStoreProcedure),
typeof(System.Drawing.Design.UITypeEditor))]
        [SugarColumn(IsJson = true)]
        public StoreProInfo DeleteStoredProcedure { get; set; } = new();

        /// <summary>
        /// 修改时候要执行存储过程
        /// </summary>
        [Category("\t\t\t\t\t\t\t数据源"), Description("修改时候要执行存储过程名"), DisplayName("\t\t修改")]
        [TypeConverter(typeof(ExpandableObjectConverter)), Editor(typeof(PropertyReturnStoreProcedure),
typeof(System.Drawing.Design.UITypeEditor))]
        [SugarColumn(IsJson = true)]
        public StoreProInfo UpdateStoredProcedure { get; set; } = new();

        /// <summary>
        /// 查询或者界面开始初始话的时候要执行存储过程名
        /// </summary>
        [Category("\t\t\t\t\t\t\t数据源"), Description("查询或者界面开始初始话的时候要执行存储过程名"), DisplayName("\t查询")]
        [TypeConverter(typeof(ExpandableObjectConverter)), Editor(typeof(PropertyReturnStoreProcedure),
typeof(System.Drawing.Design.UITypeEditor))]
        [SugarColumn(IsJson = true)]
        public StoreProInfo QueryStoredProcedure { get; set; } = new();

        /// <summary>
        /// 表示什么样子的类型,后期会是一个枚举
        /// </summary>
        [SugarColumn(ColumnDescription = "什么样子的类型")]
        [Description("表示什么样子类型的页面"), DisplayName("页面类型"), Category("属性配置")]
        public PageType FunctionType { get; set; }

        /// <summary>
        /// 一个页面的所控件
        /// </summary>
        [Navigate(NavigateType.OneToMany, nameof(DbControl.FunctionId))]
        [Browsable(false)]
        public List<DbControl> DbControlGs { get; set; }

        /// <summary>
        /// 把所有的控件解析成一个控件树
        /// </summary>
        [SugarColumn(IsIgnore = true),Browsable(false)]
        public List<DbControl> TreeControls { get; set; }
        /// <summary>
        /// group n t n
        /// </summary>
        [Navigate(typeof(RelationFunctionAndFunctionGroup), nameof(RelationFunctionAndFunctionGroup.FunctionId), nameof(RelationFunctionAndFunctionGroup.FunctionGroupId))]
        [Browsable(false)]
        public List<FunctionGroup> FunctionGroups { get; set; }

        /// <summary>
        /// role n to n
        /// </summary>
        [Navigate(typeof(RoleFunction), nameof(RoleFunction.FunctionId), nameof(RoleFunction.RoleId))]
        [Browsable(false)]
        public List<Role> Roles { get; set; }

        #endregion 属性

    }





}
